<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCWeb.Models.User>" %>

<%@ Register Src="../Menu/Menu.ascx" TagName="Menu" TagPrefix="uc1" %>
<%@ Register Src="../Menu/AdminMenu.ascx" TagName="AdminMenu" TagPrefix="uc2" %>
<%@ Register Src="../Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="uc3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Create User</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript">
        $(document).ready(function() {
            $("#UserForm").validate({
                rules: {
                    LogInID: {
                        required: true
                    },
                    Password: {
                        required: true,
                        minlength: 6
                    }

                },
                messages: {
                    LogInID: {
                        required: "Login ID cannot be blank"
                    },
                    Password: {
                        required: "Password cannot be blank",
                        minlength: "Password must be at least 6 characters long"
                    },
                    Email: {
                        required: "Email cannot be blank",
                        email: "Invalid email"
                    }
                }
            });
            $("#submit_view").click(function() {
                $("#IsRedirectToView").val("true");
            });
        });
    </script>

    <uc3:LogOnUserControl ID="LogOnUserControl1" runat="server" />
    <!-- BEGIN: Menu -->
    <% if (!Context.User.IsInRole("Administrators"))
       { %>
    <uc1:Menu ID="Menu1" runat="server" />
    <% }
       else
       { %>
    <uc2:AdminMenu ID="Menu2" runat="server" />
    <% } %>
    <!-- END: Menu -->
    <br />
    <br />
    <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm("CreateManager", "User", FormMethod.Post, new { id = "UserForm" }))
       {%>
    <fieldset>
        <legend>Create User</legend>
        <p>
            <label for="LogInID">
                LogIn ID:</label>
            <%= Html.TextBox("LogInID") %>
            <%= Html.ValidationMessage("LogInID", "*") %>
        </p>
        <p>
            <label for="Password">
                Password:</label>
            <%= Html.TextBox("Password") %>
            <%= Html.ValidationMessage("Password", "*") %>
        </p>
        <p>
            <label for="FName" >
                First Name:</label>
            <%= Html.TextBox("FName")%>
         </p>
         <p>   
            <label for="LName" >
                Last Name:</label>
            <%= Html.TextBox("LName")%>
        </p>
        <p>
            <label for="Email">
                Email:</label>
            <%= Html.TextBox("Email")%>
            <%= Html.ValidationMessage("Email", "*")%>
        </p>        
        <p>
            <label for="CompanyPhone">
                Office Phone:</label>
            <%= Html.TextBox("CompanyPhone")%>            
        </p>        
        <%--<p>
        <label for="Role">RoleName:</label>
        <%= Html.DropDownList("RoleName", new SelectList(System.Web.Security.Roles.GetAllRoles())) %>
        </p>--%>
        <p>
        <label for="Community">Community:</label>
            <%= Html.DropDownList("Community")%>
        </p>
        <p>
            <label for="Active">
                Active:</label>
            <%= Html.CheckBox("Active") %>
            <%= Html.ValidationMessage("Active", "*") %>
        </p>
        <p>
            <%= Html.Hidden("IsRedirectToView")%>
            <input id="submit" name="submit" type="submit" value="Save & New" />
            <input id="submit_view" name="submit_view" type="submit" value="Save & View" />            
            <input type="reset" value="Reset" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%=Html.ActionLink("Back to List", "Index") %>
    </div>
</asp:Content>
